/**
 * 
 */
package br.org.bertol.mestrado.engine.optimisation.moo;

import java.util.Comparator;
import java.util.EnumMap;

import br.org.bertol.mestrado.engine.fitness.Objective;
import br.org.bertol.mestrado.engine.optimisation.entity.AbstractUnit;

/**
 * @author contaqualquer
 * @param <U>
 *            Tipo de entidade
 */
public class OrdenatePareto<U extends AbstractUnit<?>> implements Comparator<U> {

    /***/
    private final transient AbstractParetoDominace<EnumMap<Objective, Number>> dominace;

    /**
     * @param typeDominace
     *            Tipo de comparação
     */
    public OrdenatePareto(
        final AbstractParetoDominace<EnumMap<Objective, Number>> typeDominace) {
        super();
        this.dominace = typeDominace;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public final int compare(final U left, final U right) {

        final int pareto =
                dominace.compare(left
                .getHeight(),
                                 right
                .getHeight());

        return pareto;
    }

}
